package com.acme.orders.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

public class Order implements Serializable {

	private static final long serialVersionUID = -6707445481726876102L;

	private String id;
	private Customer customer;
	private List<OrderLine> orderLines;
	private Date creationDate, shippingDate;

	public String getId() {
		return id;
	}
	public Customer getCustomer() {
		return customer;
	}
	public List<OrderLine> getOrderLines() {
		return orderLines;
	}
	public Date getCreationDate() {
		return creationDate;
	}
	public Date getShippingDate() {
		return shippingDate;
	}
	
	public Order setId(String id) {
		this.id = id;
		return this;
	}
	public Order setCustomer(Customer customer) {
		this.customer = customer;
		return this;
	}
	public Order setOrderLines(List<OrderLine> orderLines) {
		this.orderLines = orderLines;
		return this;
	}
	public Order setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
		return this;
	}
	public Order setShippingDate(Date shippingDate) {
		this.shippingDate = shippingDate;
		return this;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Order other = (Order) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Order [");
		if (id != null)
			builder.append(id).append("| ");
		if (creationDate != null)
			builder.append(creationDate);
		builder.append("]");
		return builder.toString();
	}

	
}
